home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Online / SpeakFreely / src / adpcm / rawcaudio.c < prev    next >
C/C++ Source or Header  |  2000-05-18  |  485b  |  30 lines

  1. /* testc - Test adpcm coder */
  2.  
  3. #include "adpcm.h"
  4. #include <stdio.h>
  5.  
  6. struct adpcm_state state;
  7.  
  8. #define NSAMPLES 1000
  9.  
  10. char    abuf[NSAMPLES/2];
  11. short    sbuf[NSAMPLES];
  12.  
  13. main() {
  14.     int n;
  15.  
  16.     while(1) {
  17.     n = read(0, sbuf, NSAMPLES*2);
  18.     if ( n < 0 ) {
  19.         perror("input file");
  20.         exit(1);
  21.     }
  22.     if ( n == 0 ) break;
  23.     adpcm_coder(sbuf, abuf, n/2, &state);
  24.     write(1, abuf, n/4);
  25.     }
  26.     fprintf(stderr, "Final valprev=%d, index=%d\n",
  27.         state.valprev, state.index);
  28.     exit(0);
  29. }
  30.